home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / news193.zip / LANMAG.TXT < prev    next >
Text File  |  1991-04-22  |  12KB  |  296 lines

  1. We at Artisoft are excited about the opportunity to communicate directly
  2. to our LANtastic users.  We'll be providing you with solutions for some
  3. common problems, sharing some helpful hints, and encouraging you to try
  4. more of LANtastics many features.  This column will cover some of the
  5. batch file programming techniques useful in setting up larger more
  6. complicated networks. 
  7.  
  8. Network Management
  9.  
  10. Many LANtastic networks start simply, designed to allow users to share an
  11. expensive peripheral device or  information in a common data base.  As
  12. the users become more familiar with the operation and advantages of a
  13. network, more nodes are added, both as servers and workstations, and
  14. managing the network becomes more complicated. 
  15.  
  16. As the network grows the simple batch files described in the previous
  17. column become more cumbersome.  Each user on the network does not
  18. have the same needs, and certainly do not need access to the same
  19. programs.  Setting up an individual batch file on each machine limits each
  20. user to his assigned computer.  If Bill works in accounting, and John
  21. works in production, neither one can work at the others machine without
  22. reconfiguring the network connections on each machine.  
  23.  
  24. This column will use the LANtastic NET STRING command to present a
  25. scheme that allows each computer's network connections to be configured
  26. by user and not computer.  The LANtasic Network Operating System
  27. Reference Manual  describes the NET STRING command as follows:
  28.  
  29.       This command assigns a STRING of characters to a pre-
  30.       existing environmental variable that is either typed in 
  31.       by the user or extracted from one of LANtastic's special
  32.       Strings. You can use these Strings just like DOS environmental
  33.       Strings.  These are useful for prompting users to enter their
  34.       passwords, user names or any other information. It is
  35.       especially useful in batch files  . . .
  36.  
  37. This short paragraph states the purpose of the command but not the
  38. implications.  The NET String command allows the system administrator
  39. to create batch files that are truly interactive!  The command allows the
  40. administrator to store vital network information in environmental variables
  41. that can be used by other batch files.  The NET STRING command will
  42. work with or without the network running.
  43.  
  44. The syntax is:  NET STRING (/LEFT=n)(/RIGHT=n) variable String1 String2
  45.  
  46. /LEFT                       First character from the left that will be
  47.                         extracted from a String.
  48. /RIGHT                      The last character that will be extracted from
  49.                         a String.
  50. Variable                    Pre-existing environmental variable to receive
  51.                         a String.
  52. STRING1                     STRING to replace environmental variable.
  53. STRING2                     Optional sting to be concatenated with String 1
  54.  
  55.  
  56. The environmental variable is defined within a batch file with the set
  57. command.  Enough characters must be allocated for the largest entry you
  58. wish to permit.  
  59.  
  60. The syntax to define a variable is:  SET name=xxxxxxxx
  61.  
  62. Name is the name of the variable. The x's allocate the space, in this
  63. example the variable name is allowed to be 8 characters long.
  64.  
  65. When the pre-existing environmental variable is defined in the autoexec.bat
  66. file then any changes made to the String will  remain in effect until the
  67. system is rebooted or the variable is changed with the NET STRING
  68. command.  If the variable is defined in another batch file the variable is
  69. local to that batch file. The String and it's contents are lost when the batch
  70. file ends.
  71.  
  72. The LANtastic special Strings are listed in the beginning of the NET Line
  73. Commands section of the manual.  The special Strings used in this column
  74. are:
  75.  
  76. ?"prompt"            Prompts the user for input, and echoes input to
  77.                   screen.
  78. ^"prompt"            Prompts the user for input, and DOES not echo input
  79.                   to screen.
  80. !"ETEXT=n"           Expands the error number n to text.
  81. !"INSTALLED"         Expands to characters corresponding to installed
  82.                   programs. N=NETBIOS, R=REDIR,S=SERVER, L=LANPUP, 
  83.                   -=Not installed.
  84. !"LOGIN=server"      Returns TRUE if already logged into server FALSE
  85.                   if not
  86. !"NODEID"            Expands to 12 digit NETBios Node number.
  87. !"MACHINEID"         Expands to name of machine being used.
  88.  
  89. Lets set up a simple network. we will use the network described in the
  90. previous column.  We have five computers, three ATs and two XTs.  Each
  91. AT has one 40MB hard drive and one printer.  Both XTs have 2 floppy
  92. drives but no hard drives or printers.  Each AT has LANtastic installed as
  93. a server.  We will name the ATs AT1, AT2, and AT3, and call the XTs XT1
  94. and XT2.  AT1 will be the master computer on the network.  This means
  95. that AT1 will always be booted as a server, and will contain the batch files
  96. that administer the network in a directory named NET.MGR.
  97.  
  98. The autoexec.bat file for AT2 and AT3 is listed below the standard DOS
  99. prompt etc. left out for clarity:
  100.  
  101. PATH=c:\lantasti;c:\dos;c:\bat;c\util
  102.  REM Path including LANtastic directory   
  103. SET answer=xxxxxxxxxxxxxxxxxxxx
  104. SET name=xxxxxxx                        
  105. SET password=xxxxxxxx
  106.  REM Define environmental variables for use            
  107. NET STRING answer ?"Install Lantastic Network (y/N)"
  108.  REM Print STRING in quotes, wait for response, and place response in
  109.  REM variable answer 
  110. IF NOT %answer%==Y GOTO exit
  111.  REM if response anything but Y exit to dos without installing network, NET
  112.  REM STRING converts character to upper case   
  113. LANBIOS2/AUTO
  114.  REM Install netbios                      
  115. REDIR ATn LOGINS=3 BUFFERS=2
  116.  REM Install redirector            
  117. NET STRING answer ?"Install as a LANtastic Server (y/N)"
  118.  REM Print String in quotes, wait for response, and place response in
  119.  REM variable answer 
  120. IF NOT %answer%==Y GOTO login
  121.  REM if response anything but Y, continue without installing server 
  122. SERVER
  123.  REM Load server 
  124. :login
  125. login
  126.  REM  Run login.bat 
  127. :exit
  128.  
  129. The autoexec.bat for AT1 is:
  130.  
  131. PATH=c:\lantasti;c:\dos;c:\bat;c\util
  132. SET answer=xxxxxxxxxxxxxxxx                       
  133. SET name=xxxxxxx                        
  134. SET password=xxxxxxxx     
  135. LANBIOS2/AUTO                             
  136. REDIR AT1 LOGINS=3 BUFFERS=2
  137. SERVER
  138. login
  139.  
  140. The following batch files login.bat and logout.bat are  the same on  all
  141. computers on the network.
  142.  
  143. LOGIN.BAT
  144.  
  145. @ECHO OFF
  146. SET NET_ERROR=XXX
  147. :start
  148. NET STRING name ?"Please enter your user name"
  149.  REM prompt for user name  store in variable name 
  150. NET STRING password ^"Please enter your password"
  151.  REM prompt for password store in variable password 
  152. NET STRING/LEFT=3/RIGHT=3 answer !"INSTALLED"
  153.  REM get the third character of string returned by !"INSTALLED" special
  154.  REM string
  155.  REM check to see if server is loaded, you cannot have spaces before /left
  156.  REM of /right 
  157. IF NOT %answer%==S GOTO redir
  158.  REM if server is not installed go to redir and log onto master server
  159. NET STRING answer !"Machineid"
  160.  REM determines the local name of the computer
  161. NET/NOERROR LOGIN \\%answer%  %name% %password%
  162.  REM server logs into itself 
  163. IF %NET_ERROR%==86 GOTO start
  164. REM If login attempt unsuccessful due to invalid user name or password
  165. REM try again
  166. NET USE lpt1 \\ATn\@printer
  167.  REM and attaches to it's own printer 
  168. :REDIR
  169. NET STRING answer !"LOGIN=AT1"
  170.  REM Check to see if already logged into server AT1 
  171. IF %answer%==TRUE GOTO login
  172.  REM  if already logged into server AT1 do not attempt it again
  173. NET LOGIN/WAIT \\AT1 %name% %password%
  174.  REM  login into master server
  175. NET USE z: \\AT1\MANAGER
  176.  REM  attach to shared resource Manager that is the \\AT!\c:\net.mgr
  177. :login
  178. SET tempname=xxxxxxxx
  179. NET STRING tempname %name% i
  180. CALL z:\%tempname%
  181.  REM  run the unique login file for the user, username+I.bat ie johnI.bat
  182. SET password=x
  183.  REM  set the password to x so no one can discover your password
  184.  
  185. Logout.BAT
  186. SET tempname=xxxxxxxx
  187. NET STRING %tempname% %name% o
  188. CALL z:\%tempname%
  189.  REM run the unique batch file to log user off system, username+O.bat ie.
  190.  REM johnO.bat
  191. CALL reset
  192. REM restore current PATH
  193.  
  194. The final pieces of this system are the individual batch files for each user. 
  195. These batch files are named with username with the letter i added to the
  196. end of the login files and the letter o added to the logout files.  These files
  197. contain the necessary commands to log each user onto the server he
  198. needs to use and attach to the shared resources on that server.  Thus
  199. each user will have two batch files in the net.mgr directory of server AT1. 
  200. Each computer may have batch file for network configuration commands
  201. peculiar to the individual computer.
  202.  
  203. Below are sample login and logout batch files:
  204.  
  205. Johni.bat - login batch file for user John
  206.  
  207. NET LOGIN/WAIT \\AT2 %name% %password%
  208. REM attempt to login to server AT2 if server AT2 is not available wait until
  209. REM it comes up or user presses escape key
  210. NET LOGIN/WAIT \\AT3 %name% %password%
  211. NET STRING/LEFT/RIGHT answer !"server=at2"
  212. IF %answer%==- GOTO noat2
  213. REM if login to at2 not successful skip attempt to use resources
  214. NET USE d: \\AT2\c-drive
  215. NET USE LPT2 \\AT2\@printer
  216. :noat2
  217. NET STRING/LEFT/RIGHT answer !"server=at3"
  218. IF %answer%==- GOTO noat3
  219. REM if login to at3 not successful skip attempt to use resources
  220. NET USE e: \\AT3\c-drive
  221. :noat3
  222. NET USE f: \\AT1\wp
  223. NET USE g: \\AT1\123data
  224. PATH>RESET.BAT
  225. REM save copy of current path to file on local drive reset.bat
  226. PATH=%PATH%;f:\;g:\
  227. REM add new directories to path
  228. NET STRING answer !"machineid"
  229. REM get name of node
  230. SET tempname=xxxxxxxxxxxx
  231. NET STRING tempname %answer% .bat
  232. IF EXIST z:\%tempname% call %answer%
  233. REM if a node specific batch file exists run it
  234.  
  235. Johno.bat - logout file for user John
  236.  
  237. NET/NOERROR LOGOUT \\at1
  238. REM suppress error messges with the /NOERROR switch just in case
  239. REM already logged out
  240. NET/NOERROR LOGOUT \\at2
  241. NET/NOERROR LOGOUT \\at3
  242.  
  243. The following is an example of a machine specific login file for AT2 that
  244. has a modem on com2.
  245.  
  246. AT2.BAT
  247.  
  248. NET STRING/LEFT=3/RIGHT=3 answer !"Installed"
  249. REM  is server running
  250. IF %ANSWER%==S NET QUEUE HALT \\at2 com2
  251. REM If computer is a server halt the spooling to com port #2
  252.  
  253. While these files may appear to be complicated or hard to use once they
  254. are setup the job of the system administrator becomes very easy.  When
  255. a new node is added to the network you only need to copy autoexec.bat,
  256. login.bat and logout.bat to the new computer.  The autoexec.bat will only
  257. need to be edited to set the network name for the computer and change
  258. the settings on the netbios if they are not the default settings.  All other
  259. files are stored in the net.mgr directory on the master server.  The access
  260. permissions can be set for the net.mgr so that no one else can edit the
  261. files.
  262.  
  263. The NET STRING command can be used in many other places.  Almost
  264. any batch file can benefit from the NET STRING command.  With a little
  265. ingenuity an entire menu driven system can be developed using only
  266. standard batch commands and NET STRING.  Even if you do not use the
  267. batch files in presented in this column their example should explain the
  268. operation of this very powerful but seldom used command.
  269.  
  270.  
  271. I've tried to make this column as beneficial as possible.  Please feel free
  272. to contact us if you have any questions or if there is a subject you would
  273. like us to cover.
  274.  
  275. If you're experiencing a problem, our Technical Support department and
  276. electronic bulletin board service (ARTIFACTS BBS) are available at no
  277. charge.  You may call or write to ARTISOFT at:
  278.  
  279. Artisoft Inc.
  280. Public Relations/Lan Times
  281. 575 E. River Rd.
  282. Tucson, Az.  85704
  283. Tele: (602) 293-6363
  284. FAX:  (602) 293-8065
  285. BBS: (602) 293-0065
  286.  
  287. Note:  These batch files were developed using LANtastic NOS V3.0x.  The
  288. version 3.00 introduced several new features including the NET
  289. LOGIN/WAIT command used in these batch files.  The software upgrade
  290. is available from Artisoft for $50.00.
  291.  
  292. THIS ARTICLE REPRODUCED HERE WITH THE PERMISSION OF "LAN MAGAZINE"
  293.  
  294.  
  295.  
  296.